<template>
  <div class="hire">

    <el-table :data="tableData" border style="width: 100%">
      <el-table-column prop="photo" align="center" label="图片">
        <template slot-scope="scope">
          <img :src="scope.row.photo" style="width:100px;height:80px;" alt>
        </template>
      </el-table-column>
      <el-table-column prop="name" align="center" label="信息" />
      <el-table-column prop="phone" align="center" label="联系方式" />
      <el-table-column prop="size" align="center" label="大小" />
      <el-table-column prop="area" align="center" label="地址" />
      <el-table-column prop="money" align="center" label="租金" />
      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-button size="small" type="success" @click="handleClick(scope.row)">查看详情</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <el-col :span="24" class="toolbar" style="text-align: center;">
      <el-pagination
        background
        :current-page="currentPage"
        :page-count="pageNum"
        :page-size="pagesize"
        style="margin-top:30px;margin-bottom:30px"
        layout="total, prev, pager, next, jumper"
        :total="total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </el-col>
  </div>
</template>
<script>
export default {
  data() {
    return {
      currentPage: 1, // 初始页
      pagesize: 10, // 当前页面内的列表行数
      pageCount: 1,
      pageNum: 1, // 页数
      total: 2,
      tableData: [
        {
          name: '三室一厅两卫',
          size: '120m²',
          money: '2000元/月',
          photo:
            'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1577352671&di=520043bbe47812da2160801cf53b9524&imgtype=jpg&er=1&src=http%3A%2F%2Fimg.tuituifang.com%2F4%2Ftmp%2F20110619%2F13%2F1308448093105962909.jpg',
          phone: '13455555555',
          area: '浙江省杭州市下城区下沙大都会风情苑8幢6单元902室'
        },
        {
          name: '两室一厅一卫',
          size: '80m²',
          money: '1500元/月',
          photo:
            'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1576757986762&di=159c06bb219c3753aef8fd305b5bbf1c&imgtype=0&src=http%3A%2F%2Fxmwb.xinmin.cn%2Fxmwbusa%2Fresfile%2F2013-07-26%2FB16%2Fp26_b.jpg',
          phone: '13456867816',
          area: '浙江省杭州市下城区下沙大都会风情苑11幢1单元101室'
        }
      ]
    }
  },
  mounted() {},
  methods: {
    handleClick(row) {
      this.$router.push({ name: '房屋租赁详情', params: { data: row }})
    },
    // 当前页
    handleSizeChange: function(pagesize) {
      this.pagesize = pagesize
    },
    // 换页：更新列表数据
    handleCurrentChange: function(currentPage) {
      this.currentPage = currentPage
    }
  }
}
</script>
<style lang="scss" scoped>
.hire {
  margin-top: 55px;
}
</style>
